package com.jdiv.samples.full;

import com.jdiv.JDiv;
import com.jdiv.JProcess;

public class Ben extends JProcess {

	int punchCount=0;

	int anim[][]=new int[36][2];

	int time=10;

	int limit=time;
	
	boolean finAnim=false;
	
	public Ben() {
		super();
		graph=42;
		x=120; //114
		y=47;  //30
		
		JDiv.mouse.graph=44;
		
		//Coordenads de cada Frame de ben
        //      X               Y
		anim[0][0]=114; anim[0][1]=32;
		anim[1][0]=113; anim[1][1]=40;
		anim[2][0]=118; anim[2][1]=41;
		anim[3][0]=120; anim[3][1]=41;
		anim[4][0]=120; anim[4][1]=48;
		anim[5][0]=120; anim[5][1]=52;
		anim[6][0]=120; anim[6][1]=53;
		anim[7][0]=92; anim[7][1]=44;
		anim[8][0]=102; anim[8][1]=39;
		anim[9][0]=120; anim[9][1]=43;
		anim[10][0]=113; anim[10][1]=36;
		anim[11][0]=113; anim[11][1]=35;
		anim[12][0]=116; anim[12][1]=34; 
		anim[13][0]=120; anim[13][1]=37;
		anim[14][0]=114; anim[14][1]=32;
		anim[15][0]=114; anim[15][1]=32;		
		anim[16][0]=113; anim[16][1]=37;
		anim[17][0]=112; anim[17][1]=39;		
		anim[18][0]=111; anim[18][1]=40;
		anim[19][0]=111; anim[19][1]=41;		
		anim[20][0]=111; anim[20][1]=42;
		anim[21][0]=111; anim[21][1]=30;		
		anim[22][0]=111; anim[22][1]=29;
		anim[23][0]=121; anim[23][1]=29;
		anim[24][0]=141; anim[24][1]=30;
		anim[25][0]=174; anim[25][1]=28;
		anim[26][0]=174; anim[26][1]=93;
		anim[27][0]=215; anim[27][1]=163;
		anim[28][0]=204; anim[28][1]=137;
		anim[29][0]=207; anim[29][1]=138;
		anim[30][0]=207; anim[30][1]=138;
		anim[31][0]=203; anim[31][1]=135;
		anim[32][0]=203; anim[32][1]=126;
		anim[33][0]=203; anim[33][1]=120;
		anim[34][0]=203; anim[34][1]=118;
		anim[35][0]=203; anim[35][1]=118;
	
	}

	public void begin() {}

	public void loop(){

	if (JDiv.mouse.left && time>limit && !finAnim){
		 graph++;
	
 	    punchCount++;
		
			if (punchCount<4){
				for (graph = 43 ; graph > 42; graph--){

					frame(80);
				}
			}else{
				x=114;
				y=30;
				for (graph = 5 ; graph < 40; graph++){
					if (graph>26) x++;
				
					x=anim[graph-5][0];
				    y=anim[graph-5][1];
				     
					frame(80);
				}
				finAnim=true;
			}
			time=0;	
		}
	
	 if (finAnim){
		//JDiv.write(1,165,40,1,"Hola soy ben y estoy corriendo sobre JDiv");
		JDiv.write(1,210,30,1,"Hola  soy  ben  y  estoy");
		JDiv.write(1,210,45,1,"corriendo  sobre  JDiv");
	
	 }
		
	time++;	
	}

}
